import unittest
import datetime

from meercat.base.instance import Instance
from meercat.base.metadata import Metadata
from meercat.base.resource import Resource


class MetadataTest(unittest.TestCase):
    def setUp(self):
        self.metadata = Metadata(source='testS',format='testF',value='testV')
    
    def testEquality(self):
        self.assert_(self.metadata == Metadata(source='testS',format='testF',
                                                value='testV'))
        
        self.assertFalse(self.metadata == Metadata(source='testS',format='testF',
                                                   value='test1'))
        self.assertFalse(self.metadata == Metadata(source='testS',format='test1',
                                                   value='testV'))
        self.assertFalse(self.metadata == Metadata(source='test1',format='testF',
                                                   value='testV'))
        
        self.assertFalse(self.metadata == ('test','test','test'))
    
    def testAccessors(self):
        self.assertEqual(self.metadata.getFormat(),'testF')
        self.assertEqual(self.metadata.getSource(),'testS')
        self.assertEqual(self.metadata.getValue(),'testV')
    
    def testHashing(self):
        self.assertEqual(self.metadata.__hash__(),
                         Metadata(source='testS',format='testF',
                                                value='testV').__hash__())

def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(MetadataTest))
    return suite

if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(test_suite())